package com.corticon.dialogs.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * LoanProduct entity.
 *
 * @author Yanglifan
 */
@Entity
@Table(name = "loanproduct")
public class LoanProduct extends AuditableEntity implements Serializable {

    private Long loanProductId;
    private RiskRating riskRating;
    private String id;
    private Long interestRate;
    private Long maxAmount;
    private Long maxIncome;
    private Long minIncome;
    private Long termMonths;
    private Set<Quote> quotes = new HashSet<Quote>();

    public LoanProduct() {
    }

    // Property accessors
    @Id
    @SequenceGenerator(name = "loanproduct_id_seq",
            sequenceName = "loanproduct_id_seq",
            allocationSize = 1, initialValue = 1)
    // Set allocationSize and initialValue
    // to let sequence increment following DB.
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "loanproduct_id_seq")
    @Column(name = "loanproduct_id",  nullable = false, columnDefinition = "integer")
    public Long getLoanProductId() {
        return this.loanProductId;
    }

    public void setLoanProductId(Long loanProductId) {
        this.loanProductId = loanProductId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "rrassoc_rr_id_oid")
    public RiskRating getRiskRating() {
        return this.riskRating;
    }

    public void setRiskRating(RiskRating riskrating) {
        this.riskRating = riskrating;
    }

    @Column(name = "id", length = 256)
    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(name = "interestrate", columnDefinition = "numeric")
    public Long getInterestRate() {
        return this.interestRate;
    }

    public void setInterestRate(Long interestRate) {
        this.interestRate = interestRate;
    }

    @Column(name = "maxamount")
    public Long getMaxAmount() {
        return this.maxAmount;
    }

    public void setMaxAmount(Long maxAmount) {
        this.maxAmount = maxAmount;
    }

    @Column(name = "maxincome")
    public Long getMaxIncome() {
        return this.maxIncome;
    }

    public void setMaxIncome(Long maxIncome) {
        this.maxIncome = maxIncome;
    }

    @Column(name = "minincome")
    public Long getMinIncome() {
        return this.minIncome;
    }

    public void setMinIncome(Long minIncome) {
        this.minIncome = minIncome;
    }

    @Column(name = "termmonths")
    public Long getTermMonths() {
        return this.termMonths;
    }

    public void setTermMonths(Long termMonths) {
        this.termMonths = termMonths;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "loanProduct")
    public Set<Quote> getQuotes() {
        return this.quotes;
    }

    public void setQuotes(Set<Quote> quotes) {
        this.quotes = quotes;
    }
}